#ifndef LOGMGR_H
#define LOGMGR_H

#pragma once

#include <cstdio>
#include <chrono>

// #include <vector>
#include <memory>



//use spdlog log version is 1.15.0



// critical 5(最严重的错误)
// error 4
// warn 3
// info 2
// debug 1
// trace 0(最详细的调试信息)

// enable/disable log calls at compile time according to global level.
// define SPDLOG_ACTIVE_LEVEL before including spdlog.h
#define SPDLOG_ACTIVE_LEVEL 2


#include "spdlog/spdlog.h"
#include "spdlog/cfg/env.h"   // support for loading levels from the environment variable

#include "spdlog/async.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#include "spdlog/sinks/daily_file_sink.h"


class LogMgr
{
private:

public:
    LogMgr();
    ~LogMgr();
};


#define LOG_TRACE(...) do { \
    auto console = spdlog::get("console"); \
    if (console) \
        SPDLOG_LOGGER_TRACE(console, __VA_ARGS__); \
    \
    auto async_file_logger = spdlog::get("async_file_logger"); \
    if (async_file_logger) \
        SPDLOG_LOGGER_TRACE(async_file_logger, __VA_ARGS__); \
    } while (0)
    
#define LOG_DEBUG(...) do { \
    auto console = spdlog::get("console"); \
    if (console) \
        SPDLOG_LOGGER_DEBUG(console, __VA_ARGS__); \
    \
    auto async_file_logger = spdlog::get("async_file_logger"); \
    if (async_file_logger) \
        SPDLOG_LOGGER_DEBUG(async_file_logger, __VA_ARGS__); \
    } while (0)

#define LOG_INFO(...) do { \
    auto console = spdlog::get("console"); \
    if (console) \
        SPDLOG_LOGGER_INFO(console, __VA_ARGS__); \
    \
    auto async_file_logger = spdlog::get("async_file_logger"); \
    if (async_file_logger) \
        SPDLOG_LOGGER_INFO(async_file_logger, __VA_ARGS__); \
    } while (0)

#define LOG_WARN(...) do { \
    auto console = spdlog::get("console"); \
    if (console) \
        SPDLOG_LOGGER_WARN(console, __VA_ARGS__); \
    \
    auto async_file_logger = spdlog::get("async_file_logger"); \
    if (async_file_logger) \
        SPDLOG_LOGGER_WARN(async_file_logger, __VA_ARGS__); \
    } while (0)

#define LOG_ERROR(...) do { \
    auto console = spdlog::get("console"); \
    if (console) \
        SPDLOG_LOGGER_ERROR(console, __VA_ARGS__); \
    \
    auto async_file_logger = spdlog::get("async_file_logger"); \
    if (async_file_logger) \
        SPDLOG_LOGGER_ERROR(async_file_logger, __VA_ARGS__); \
    } while (0)

#define LOG_CRITICAL(...) do { \
    auto console = spdlog::get("console"); \
    if (console) \
        SPDLOG_LOGGER_CRITICAL(console, __VA_ARGS__); \
    \
    auto async_file_logger = spdlog::get("async_file_logger"); \
    if (async_file_logger) \
        SPDLOG_LOGGER_CRITICAL(async_file_logger, __VA_ARGS__); \
    } while (0)
    

#endif  // LOGMGR_H
